package cate.common.table.item.rune.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cate.common.table.item.rune.SkillGroupList;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

@NoteClass(value = "符文技能特殊洗练")
public class RuneRecastSkillTypeRow extends ERow {

    @NoteField(value = "技能等级组合")
    private String skillLevelStr;

    @NoteField(value = "洗练消耗")
    public String consumeStr;

    @NoteField(value = "洗练技能组")
    private String skillGroupStr;

    @NoteField(value = "幸运技能组配置")
    public String luckySkillStr;

    @NoteField(value = "幸运重铸分组2")
    public String luckySkillChooseStr;

    @NoteField(value = "幸运重铸分组3")
    public String luckySkillNotUseItemStr;

    @Override
    public void parse(XSSFRowWrap xr) {
        this.id = xr.getInteger("ID", -1);
        this.skillLevelStr = xr.getString("技能等级组合");
        this.consumeStr = xr.getString("洗练消耗");
        this.skillGroupStr = xr.getString("洗练技能组");
        this.luckySkillStr = xr.getString("技能幸运分组1");
        this.luckySkillChooseStr = xr.getString("幸运重铸分组2");
        this.luckySkillNotUseItemStr = xr.getString("幸运重铸分组3");
    }

    /** 技能等级组合 */
    public List<Integer> levelCombo = new ArrayList<>();
    /** 洗练技能组 */
    public SkillGroupList skillGroup;
    /** 幸运洗练技能组 */
    public SkillGroupList luckySkillGroup;

    public List<Integer> luckyChooseSkillGroups;

    public List<Integer> luckySkillNotUseItemGroups;

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(skillLevelStr)) {
            levelCombo = Str.strArr2intList(skillLevelStr.split("#"));
            levelCombo.sort(Comparator.comparing(a -> a));
        }

        skillGroup = new SkillGroupList();
        if (StringUtils.isNotBlank(skillGroupStr)) {
            skillGroup.parse(skillGroupStr);
        }

        luckySkillGroup = new SkillGroupList();
        if (StringUtils.isNotBlank(luckySkillStr)) {
            luckySkillGroup.parse(luckySkillStr);
        }

        luckyChooseSkillGroups = new ArrayList<>();
        if(StringUtils.isNotBlank(luckySkillChooseStr)){
            luckyChooseSkillGroups =  Str.strArr2intList(luckySkillChooseStr.split(","));
        }

        luckySkillNotUseItemGroups = new ArrayList<>();
        if(StringUtils.isNotBlank(luckySkillNotUseItemStr)){
            luckySkillNotUseItemGroups = Str.strArr2intList(luckySkillNotUseItemStr.split(","));
        }
    }
}
